﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WMI.root.cimv2;
using System.ComponentModel;
using System.Collections.Generic;

public class NetworkSession
{
    public uint ActiveTime { get; set; }
    public uint NumberOfFiles { get; set; }
    public string ShareName { get; set; }
    public string UserName { get; set; }
    public string ComputerName { get; set; }
    public TimeSpan ActiveTimeSpan { get; set; }
}

[DataObject(true)]
public class NetworkSessionsWrapper
{
    static public IEnumerable<NetworkSession> Sessions
    {
        get
        {
            var coll = ServerConnection.GetInstances();
            foreach (ServerConnection item in coll)
            {
                yield return new NetworkSession()
                {
                    ActiveTime = item.ActiveTime,
                    NumberOfFiles = item.NumberOfFiles,
                    ShareName = item.ShareName,
                    UserName = item.UserName,
                    ComputerName = item.ComputerName,
                    ActiveTimeSpan = TimeSpan.FromSeconds(item.ActiveTime)                    
                };
            }
        }     
    }
}
